/**
 * @author: enic
 * @date: 2018-04-12
 */

package main

import "fmt"
import "encoding/json"
import "github.com/astaxie/beego"
import "github.com/astaxie/beego/context"

// UserListData golint要求导出类必须这样注释，否则会出警告
/**
 * @brief: 玩家列表数据
 * @desc: ！只有大写字母开头的变量才会被json.Marshal自动转换到json字符串中去
 */
type UserListData struct {
	UserID   int
	Account  string
	NickName string
}

func main() {
	//beego.SetStaticPath("/h5", "h5")

	beego.Get("/", func(ctx *context.Context) {
		ctx.Redirect(302, "static/h-ui-admin/index.html")
	})

	beego.Get("/GetUserList", func(ctx *context.Context) {
		//ctx.Output.JSON("bob", false, false)
		data := &UserListData{}

		data.UserID = 10010
		data.Account = "enic001"
		data.NickName = "enic001"

		jsonData, err := json.Marshal(data)
		if err != nil {
			fmt.Println("Json.Marshal:", err)
		}

		fmt.Println(string(jsonData))
		ctx.Output.JSON(string(jsonData), false, false)
	})

	beego.Run()
}
